
<template>
<view> 
	<cu-custom :customStyle="{backgroundColor:'#fff',zIndex:1}" :isBack="true" :paddingHeight="48">
		<block #backText>返回</block>
		<block #content><span style="font-size: 38rpx;">编辑任务活动信息</span></block>
	</cu-custom>
	
	<view style="position: relative;">
			<!-- 主卡片 -->
			<view style="background-color: white;position: relative;">

				<view style="border-radius: 10rpx;margin: 0px 0px 10px 0px;padding: 0rpx;background-color: white;">
					<view v-if="taskFormData.id"  @click="onPreveiw" style="color:white;background-color: #eea700;text-align: center;padding: 10px;margin: 10px;border:solid 1rpx #eee">
						<view style="display: inline-block;">
							<u-icon name="eye" color="white"></u-icon>
						</view>
						预览
					</view>
					
					<u-cell-group :border="false">
						<!-- 开始时间 -->
						<u-cell 
							title="开始日期"
							isLink 
							@click="showActivityStartDateTimeSel = true">
							<template #value>
								<view style="">{{$dayjs(taskFormData.start_date).format('YYYY-MM-DD')}}</view>
							</template>
						</u-cell>
						
<!-- 						<u-cell
							title="最后报名时间"
							isLink 
							@click="showActivityLastEnrollTimeSel = true">
							<template #value>
								<view style="">{{$dayjs('1970-01-01 '+ taskFormData.last_enroll_time).format('a HH:mm')}}</view>
							</template>
						</u-cell> -->
						
						<u-cell
							title="集合地点"
							isLink 
							@click="choosePos">
							<template #value>
									<view style="display: flex;">
										<u-icon name="map"></u-icon>
										<view style="font-size: 26rpx">{{taskFormData.location_name}}</view>
									</view>
							</template>
						</u-cell>
						
						<view v-if="taskFormData.address" style="padding: 5px 10px;">
							<view style="display: flex">
								<view>{{taskFormData.province}}-{{taskFormData.city}}-{{taskFormData.district}}</view>
							</view>
							<view style="font-size: 18rpx;color:#999">{{taskFormData.address}}</view>
						</view>
						
						<u-cell title="群二维码" isLink  >
<!-- 							<template #value>
									<view style="display: flex;">
										<u-image width="60" height="60" :src="absUrl('/static/wx.jpg')"></u-image>
									</view>
							</template> -->

							<template #value>
								<u-upload
									:fileList="picList"
									@afterRead="afterRead"
									@delete="deletePic"
									name="1"
									:maxCount="1"
								></u-upload>
							</template>
														

						</u-cell>
						
						<u-cell title="视频" isLink  >
								<template #value>
									<u-upload
										:fileList="videoList"
										@afterRead="afterReadVideo"
										@delete="deleteVideo"
										accept="video"
										name="2"
										:maxCount="1"
									></u-upload>
								</template>
							</u-cell>
						
					</u-cell-group>
				</view>
				
				<!-- 标题内容 -->
				<view class="u-page" >
					<view style="padding:10px 0;font-size:15px;font-weight:bold;">活动说明:</view>
					<!-- 文案内容编辑器 -->
					<view style="height: 160px;">
						<editor id="editor" style="height: 100%;min-height: 120rpx;" class="ql-container" :placeholder="placeholder" @input="onEditInput" @ready="_onEditorReady"></editor>
					</view>
				</view>
				
				<!-- 添加附件入口 板块-->
				<view v-if="false" style="margin-top: 1px;padding: 20rpx;background-color: white;">
					<!-- 添加附件入口 -->
					<view @click="showAddAssets = true" style="display: flex;justify-content: flex-start;align-items: center;">
						<!-- 加号 -->
						<view style="border: solid 1px #b4b4b4;display: inline-block;border-radius: 10rpx;">
							<view style="width: 50rpx;height: 50rpx;display: flex;align-items: center;justify-content: center;">
								<u-icon name="plus" color="#b4b4b4"></u-icon>
							</view>
						</view>
						
						<span style="margin-left: 10rpx;font-size: 20rpx;color: #b4b4b4;">添加图文/视频/文件/公众号/小程序</span>
					</view>
				</view>
				 
				 <!-- 更多设置 -->
				<view v-if="false" style="border-radius: 10rpx;margin: 0px 10px 0px 10px;padding: 20rpx;background-color: white;">
					  <u-collapse
						:border="false"
						@change="change"
					  >
						<u-collapse-item
						  title="更多设置"
						  name="Docs guide"
						>
						  <u-cell-group :border="false">
								<!-- 活动通知 -->
								<u-cell title="活动通知" value="未关注公众号不能接收提醒" isLink :customStyle="{color:'#fff'}">
								</u-cell>
							</u-cell-group>
						</u-collapse-item>
					  </u-collapse>
				</view>
				
				<view>
					<view v-if="taskFormData.id" style="border:  solid 1rpx #eee;">
						<view @click="onAddJob" style="text-align: center;padding: 10px;margin: 10px;border:solid 1rpx #eee">
							<view style="display: inline-block;">
								<u-icon name="plus"></u-icon>
							</view>
							添加岗位
						</view>
					</view>
					
					<view style="margin: 0 10px;">
						<view  class="bottom_line" v-for="(job,index) in taskFormData.jobs" style="display: flex;justify-content: space-between;align-items:center;line-height: 12px;padding: 0px 0px;">
							<!-- 内容区域 -->
							<view style="flex: 1 0 0%;display: flex;flex-direction: column;padding: 2px;">
								<view style="padding: 8px;display: flex;justify-content: space-between;align-items: center;flex-wrap: nowrap;">		
									<!-- 职位名称 -->
									<view style="flex: 1 1 55%;display: flex;justify-content: space-between;">
										<view style="font-size: 13px;font-weight: bold;white-space: nowrap;"><text>{{job.name}}</text></view>
									</view>
									<!-- 时间 -->
									<view style="flex:0 0 45%;text-align: right;color:#757575">
										<view style="line-height: 13px;font-size: 13px;font-weight: bold;white-space: nowrap;"><text>{{fixedTime(job.start_time)}}-{{fixedTime(job.end_time)}}</text></view>
									</view>
								</view>
								
								<view style="display: flex;justify-content: space-between;padding:0px 3px;">
									<view>
										<view style="margin: 5px 5px;padding: 2px 10px;border-radius: 50px;color:white;background-color: #ffa200;font-size: 10px;display: inline-block">
											<text>男生</text>
										</view>
										<view style="margin: 5px 5px;padding: 2px 10px;border-radius: 50px;color:white;background-color: #ffa200;font-size: 10px;display: inline-block">
											<text>男生</text>
										</view>
										<view style="margin: 5px 5px;padding: 2px 10px;border-radius: 50px;color:white;background-color: #ffa200;font-size: 10px;display: inline-block">
											<text>男生</text>
										</view>
										<view style="margin: 5px 5px;padding: 2px 10px;border-radius: 50px;color:white;background-color: #ffa200;font-size: 10px;display: inline-block">
											<text>男生</text>
										</view>
									</view>
									
									<view style="display: flex;justify-content: space-between;align-items:flex-start;padding-top: 5px;">
										<!-- 工资 -->
										<view style="font-weight: bold;color: #f00;font-size: 13px;white-space: nowrap;">
											<span>{{job.price}}元/{{job.price_type}}</span>
											<span>/{{job.settle_type}}</span>
										</view>
										<!-- 人数 -->
										<span style="font-size: 12px;color: #9c9c9c;padding-left: 5px;white-space: nowrap;">1/{{job.num}}人</span>
									</view>
								</view>
							</view>
							
							<!-- 删除按钮 --> 
							<view  style="flex:0 1 0%;margin: 0 0px 0 5px;display: flex;flex-direction: column;justify-content: space-between;height: 100%;">
								<view style="padding: 10px 0;"><u-icon @click="onJobEdit(job,index)" name="edit-pen-fill" size="20"></u-icon></view>
								<view style="padding: 10px 0;"><u-icon @click="onDelete(job,index)" name="close-circle-fill" size="20"></u-icon></view>
							</view>
						</view>
					</view>
				</view>
				<!-- <button type="warn" @tap="print">打印</button> -->
			</view>
			
			<!-- 添加附件 选项弹窗 -->
			<u-popup :show="showAddAssets" :round="10" mode="bottom" @close="showAddAssets = false"  :closeOnClickOverlay="true">
				<view>
					<!-- 标题 -->
					<text style="display: flex;align-items: center;justify-content: center;padding: 20rpx;">请选择附件</text>
					
					<!-- 选择列  项目-->
					<view @click="showAddAssets = false" v-for="(item,index) in assetsItems"  style="padding: 20rpx 20rpx;display: flex;justify-content: flex-start;align-items: flex-start;border-bottom: solid 1px #f3f3f3;">
						<view >
							<i :class="assetsItemsClass(item)" style="font-size: 24px;"></i>
						</view>
						<view style="justify-content: space-between;margin-left: 10rpx;display: flex;align-items: flex-start;flex-direction: column;">
							<view style="font-size: 30rpx;">{{item.name}}</view>
							<view style="font-size: 24rpx;color: #b4b4b4;margin-top: 10rpx;">{{item.text}}</view>
						</view>
					</view>
				</view>
			</u-popup>

			<!-- 页面底衬 -->
			<view style="height: 100rpx;width: 100%;"></view>
	</view>
	
	<!-- 底部操作条 -->
	<view   style="height: 100rpx;position:fixed;bottom:0;border:solid 1rpx #eee;width:100%;display: flex;justify-content: space-between;background-color: white;">
		<view @click="allowCommit?onCancel():navigateBack()" style="flex: 0 0 50%;padding:15px">
			<view style="color: red;display: flex;align-items: center;justify-content: center;">
				{{allowCommit?'放弃修改':'返回'}}
			</view>
		</view>
		<view @click="allowCommit?showCommitModal=true:false" style="flex: 0 0 50%;padding:15px;"
			:style="{backgroundColor:allowCommit?'#ffa200':'#989898'}"
		>
			<view style="color:white;display: flex;align-items: center;justify-content: center;">
				{{taskFormData.id?'提交修改':'立即发布'}}
			</view>
		</view>
	</view>
	
	<u-datetime-picker
		title="开始时间"
		:show="showActivityStartDateTimeSel"
		:minDate="$dayjs().add(1,'minute').valueOf()"
		:maxDate="$dayjs().add(1,'month').valueOf()"
		mode="date"
		v-model="taskFormData.start_date"
		:closeOnClickOverlay="true"
		@confirm="showActivityStartDateTimeSel = false" 
		@cancel="showActivityStartDateTimeSel = false"
		@close="showActivityStartDateTimeSel = false"
	></u-datetime-picker>
	
	<u-datetime-picker
		title="最后报名时间"
		:show="showActivityLastEnrollTimeSel"
		:minDate="$dayjs().add(1,'minute').valueOf()"
		:maxDate="$dayjs().add(1,'month').valueOf()"
		mode="time"
		v-model="taskFormData.last_enroll_time"
		:closeOnClickOverlay="true"
		@confirm="showActivityLastEnrollTimeSel = false" 
		@cancel="showActivityLastEnrollTimeSel = false"
		@close="showActivityLastEnrollTimeSel = false"
	></u-datetime-picker>
	
	<u-modal 
	:show="showTipModal" 
	:showCancelButton="true" 
	:content="'确定放弃编辑吗?'" 
	@confirm="showTipModal = false;navigateBack()"
	@cancel="showTipModal = false">
	</u-modal>
	
	<u-modal
	:show="showCommitModal" 
	:showCancelButton="true" 
	:content="taskFormData.id?'确定提交修改吗?':'确定提交创建吗?'" 
	@confirm="showCommitModal = false;onComfirm()"
	@cancel="showCommitModal = false">
	</u-modal>
	
	<u-toast ref="uToast"></u-toast>
</view>
</template>

<script>
	import keyboardPrice from '@/components/liujto-keyboard/liujto-keyboard-price.vue'
	import timeTextFormat from '@/utils/mixins/time-text-format.js'
	import workData from '@/utils/data/workData.js'
	
	export default {
		components:{keyboardPrice},
		mixins:[workData,timeTextFormat],
		data() {
			return {
				picList:[],
				videoList:[],
				allowCommit:false,
				allowWatch:false,
				showTipModal:false,
				showCommitModal:false,
				tmpFormData:{
					start_date:this.$dayjs().format('YYYY-MM-DD'),
					last_enroll_time:'23:59:00',
					content:'',
					jobs:[],
					longitude:0,
					latitude:0,
					location_name:'',
					address:'',
					province:'',
					city:'',
					district:'',
					qrcode_url:''
				},
				taskFormData:null,
				showActivityStartDateTimeSel:false,
				showActivityLastEnrollTimeSel:false,
				showPeriodTimeStartSel:false, //时段
				showPeriodTimeEndSel:false, //时段
				showCycleSel:false, // 周期
				showActivityRemind:false,
				showAllowMult:false, //允许多次打卡
				showAllowRemedy:false,
				showAllowProxy:false, //'允许发布人和管理员'
				showAddAssets:false,
				editorCtx:null,
				placeholder: '开始输入...',
				rules:{
					title:{
						required: true
					}
				},
				assetsItems:[
					{
						name:'文字',
						icon:'icon-wenzi',
						text:'可插入多个文本段,达到图文混排的效果'
					},
					{
						name:'大图',
						icon:'icon-tupian1',
						text:'可完整显示图片'
					},
					{
						name:'小图',
						icon:'icon-jiugongge-line-',
						text:'九宫格显示图片'
					},
					{
						name:'视频',
						icon:'icon-shipin',
						text:'最多上传90s,不超过15M的视频'
					},
					{
						name:'附件',
						icon:'icon-fujian02',
						text:'最多可上传6个附件'
					},
					{
						name:'公众号',
						icon:'icon-weixingongzhonghao',
						text:'可跳转到公众号文章'
					},
					{
						name:'其他小程序',
						icon:'icon-xiaochengxu',
						text:'可跳转到任意小程序'
					},
					{
						name:'一键复制区',
						icon:'icon-fuzhi',
						text:'可添加网址、微信号等等、方便他人复制'
					},
					{
						name:'关联职位',
						icon:'icon-a-1',
						text:'可插入多个发布过的接龙'
					}
				],
				cycleList:[
					{
						name:'每天',
						fontSize:'34'
					},
					{
						name: '周日'
					},
					{
						name: '工作日', //开启后文字不显示
					}
				]
			}
		},
		computed:{
			assetsItemsClass()
			{
				return function(item){
					let itemsClass = {
						icon:true,
						iconfont:true
					}
					
					itemsClass[item.icon] = true
			
					return itemsClass;
				}
			}
		},
		watch: {
			'taskFormData.start_date' :function(newValue, oldValue) {
				console.log('3333333333xx')
				if(this.allowWatch) this.allowCommit = true
			}
		},
		async onLoad(options){
			console.log('XXXXXXXXX')
			console.log(this.pageParam.project)
			this.taskFormData = JSON.parse(JSON.stringify(this.tmpFormData))
			
			// if(this.pageParam.task)
			// {
			// 	console.log(this.pageParam.task)
			// 	this.taskFormData = Object.assign(this.taskFormData,this.pageParam.task)
			// 	this.picList.push({
			// 		url:this.absUrl(this.taskFormData.qrcode_url)
			// 	})
			// 	console.log(this.taskFormData)
			// }
			 
			if(options.id) 
			{
				let res = await this.$http.get(`/manager/job/task/details?job_task_id=${options.id}`)

				this.taskFormData = res.data
				console.log(this.taskFormData)
				this.picList.push({
					url:this.absUrl(this.taskFormData.qrcode_url)
				})
				this.editorCtx.setContents({
					html:this.taskFormData.content
				})
				
				console.log(this.taskFormData)
			}
		},
		onShow(){
			// console.log(this.taskFormData)
			
			setTimeout(()=>{
				this.allowWatch = true
			},1000)
		},
		methods: {
			async afterRead(event){
				console.log(event)
				
				//this.picList.push(event.file)
				
				this.picList = []
				
				let res = await this.$netTool.handleUploadFile(
					this.absUrl('/api/common/storage/upload'),  //上传接口URL
					event.file.thumb, // 要上传的文件路径
					'image', //文件类型
					'avatar', // 存储关键字,存储目录名称
					{
						"token":this.userStore.token //headers 加上令牌
					},
				);
				
				console.log(res)
				
				if(res)
				{
					let url = this.absUrl(res.data.path)
					console.log(url)
					this.picList.push({
						...event.file,
						url
					})
				}else
				{
					uni.showToast({
						icon:'error',
						title:'头像上传失败'
					})	
				}
				
				console.log(this.picList)
				
			},
			async getVideoPoster(url,width=400,height=400) {
			  //const that = this;
			  let dataURL = null
			  
			  let video = document.createElement('video')
			  video.setAttribute('crossOrigin', 'anonymous') // 处理跨域，H5需后台支持，请求的视频资源响应投标需有Access-Control-Allow-Origin
			  video.setAttribute('src', url)
			  video.setAttribute('width', width)
			  video.setAttribute('height', height)
			  video.setAttribute('preload', 'auto')
			  // uni.chooseVideo选择视频，当选用手机拍摄的视频时，地址是相对地址，如 _doc/uniapp_temp_1650594368317/camera/1650594390147.mp4
			  // 可播放，但是loadeddata一直不执行，会触发error事件，视频加载失败
			  // 应先转换成本地地址

			  return new Promise((resolve,reject)=>{
				  //上传文件
				   function dataURLtoFile(file,filename) {
				      const arr = file.split(',');
				      const mime = arr[0].match(/:(.*?);/)[1];
				      const bstr = atob(arr[1]);
					  console.log(bstr)
				      let n = bstr.length;
				      const u8arr = new Uint8Array(n);
				      while (n--) {
				        u8arr[n] = bstr.charCodeAt(n);
				      }
				  
				      return new File([u8arr], filename, {type: mime});
				   }
				  			
				  let blob = null
				  
				  video.addEventListener('loadeddata', function () {
						console.log('视频第一帧加载完')
						let canvas = document.createElement('canvas')
						let width = video.width // canvas的尺寸和图片一样
						let height = video.height
						canvas.width = width
						canvas.height = height
						canvas.getContext('2d').drawImage(video, 0, 0, width, height) // 绘制canvas
						dataURL = canvas.toDataURL('image/jpeg') // 转换为base64
		  
						console.log('getVideoPoster-dataURL', dataURL.slice(0, 16)) 
						blob = dataURLtoFile (dataURL,'video.png');
						let url = window.URL.createObjectURL(blob)
						resolve(url)
				  })
				  
				  video.addEventListener('error', err => {
						console.log('视频加载失败', err)
						reject(err)
				  })
			  })
		    },
			async afterReadVideo(event){
				console.log(event)
				
				//this.picList.push(event.file)
				
				this.videoList = []
				
				let res = await this.$netTool.handleUploadFile(
					this.absUrl('/api/common/storage/upload'),  //上传接口URL
					event.file.url, // 要上传的文件路径
					'video', //文件类型
					'avatar', // 存储关键字,存储目录名称
					{
						"token":this.userStore.token //headers 加上令牌
					},
				);
				
				console.log(res)
				
				if(res)
				{
					let url = this.absUrl(res.data.path)
					console.log(url)
					
					let posterUrl = await this.getVideoPoster(url,event.file.width,event.file.height)
					console.log(posterUrl)
					
					this.videoList.push({
						...event.file,
						url,
						thumb:posterUrl
					})
					
					console.log(this.videoList)

				}else
				{
					uni.showToast({
						icon:'error',
						title:'头像上传失败'
					})	
				}
				
				console.log(this.videoList)
				
			},
			deletePic(index,file,name){
				this.picList.splice(index,1)
			},
			onEditInput(e){
				this.allowCommit=true
			},
			navigateBack(){
				uni.navigateBack()
			},
			onJobEdit(job,index){
				this.pageParam.job =job
				uni.navigateTo({
					url:'/pages/job/publish/add-job-form'
				})
			},
			onEditorReady(){
				this.editorCtx.setContents({
					html:this.taskFormData.content
				})
			},
			openKeyboard(){
				console.log('YYYYYY')
				this.$refs.keyboard.open()
			},
			async getTaskFormData(){
				let content = await this.save()
				
				let taskFormData = {
					...this.taskFormData,
					content:content.html,
					start_date:this.$dayjs(this.taskFormData.start_date).format('YYYY-MM-DD')
				}

				return taskFormData				
			},
			async onPreveiw(){
				this.pageParam.task_details =  await this.getTaskFormData()
				this.pageParam.details_preview = true
				console.log(this.taskFormData)
				uni.navigateTo({
					url:"/pages/job/user/job-details/job-details"
				})
			},
			onAddJob()
			{
				console.log(this.taskFormData)
				this.pageParam.task = this.taskFormData
				this.pageParam.job = null
				uni.navigateTo({
					url:'/pages/job/publish/add-job-form'
				})
			},
			onCycle()
			{
				
			},
			onComfirm(){ 
				console.log(this.taskFormData)
				this.taskFormData.id ? this.updateJob() : this.createJob()
			},
			onCancel(){
				this.tipContent = '确定要取消吗'
				this.showTipModal = true
				// uni.navigateBack()
			},
			async createJob(){
				let content = await this.save()
				
				//this._showLoading()
				
				//{{taskFormData.province}}-{{taskFormData.city}}-{{taskFormData.district}}
				//this.taskFormData.latitude = res.location.latitude
				//this.taskFormData.longitude = res.location.longitude
				console.log(this.taskFormData.location_name)
				console.log(this.taskFormData.latitude)
				console.log(this.taskFormData.longitude)
				console.log(this.taskFormData.address)
				console.log(this.taskFormData.province)
				console.log(this.taskFormData.city)
				console.log(this.taskFormData.district)
				console.log(this.picList.length>0?this.picList[0].url:null)
				
				let res = await this.$http.post('/manager/job/task/create',{
					source_id:this.pageParam.project.id,
					start_date:this.$dayjs(this.taskFormData.start_date).format('YYYY-MM-DD'),
					location_name:this.taskFormData.location_name,
					latitude:this.taskFormData.latitude,
					longitude:this.taskFormData.longitude,
					address:this.taskFormData.address,
					province:this.taskFormData.province,
					city:this.taskFormData.city,
					district:this.taskFormData.district,
					qrcode_url:this.picList.length>0?this.picList[0].url:null,
					content:content.html,
					is_up_sign:true,
					is_down_sign:true,
					is_allow_resign:true,
					is_allow_agent_sign:true,
					is_notify:true,
				})
				
			   this.taskFormData = Object.assign(this.taskFormData,res.data) 
				
				// this.allowCommit = false
				
				//this.hideLoading()
			},
			async updateJob(){
				
				console.log(this.taskFormData)
				
				let content = await this.save()
				
				console.log(this.picList.length>0?this.picList[0].url:null)
				
				let taskFormData = this.$lodash.pick(
				{
					...this.taskFormData,
					content:content.html,
					qrcode_url:this.picList.length>0?this.picList[0].url:null,
				}
				,[
					'id',
					'source_id',
					'start_date',
					'content',
					'qrcode_url',
					'location_name',
					'latitude',
					'longitude',
					'address',
					'province',
					'city',
					'district',
					'is_up_sign',
					'is_down_sign',
					'is_allow_resign',
					'is_allow_agent_sign',
					'is_notify',
				])
				
				taskFormData.start_date = this.$dayjs(taskFormData.start_date).format('YYYY-MM-DD')
				
				console.log(taskFormData)
 
				uni.showLoading({
					title:'正在提交'
				})
				
				let res = await this.$http.post('/manager/job/task/update',{
					...taskFormData
				})
				
				uni.hideLoading()
				
				uni.showToast({
					title:'提交成功'
				})
				
				console.log(this.pageParam.task)
				console.log(res.data)
				//更新覆盖
				
				if(this.pageParam.task)
				{
					this.pageParam.task = Object.assign(this.pageParam.task,res.data)
				}

				setTimeout(()=>{
					this.navigateBack()
				},1000)
				
				console.log(res)
				
				this.allowCommit = false
			},
			async choosePos() {
				let res = await this.$geo.choosePos()
				
				console.log(res)
				
				this.taskFormData.location_name = res.location.name
				this.taskFormData.address = res.location.address
				this.taskFormData.latitude = res.location.latitude
				this.taskFormData.longitude = res.location.longitude
				this.taskFormData.province = res.component.result.address_component.province
				this.taskFormData.city = res.component.result.address_component.city
				this.taskFormData.district = res.component.result.address_component.district
			
				console.log(this.taskFormData)
				
				console.log(this.taskFormData.name)
				// uni.getLocation({
				// 	type: 'wgs84',
				// 	success: function (res) {
				// 		console.log('当前位置的经度：' + res.longitude);
				// 		console.log('当前位置的纬度：' + res.latitude);
				// 	}
				// });
			// 	let that = this
			// 	uni.chooseLocation({
			// 		success: function(res) {
			// 			console.log(res)
			// 			console.log('位置名称：' + res.name);
			// 			console.log('详细地址：' + res.address);
			// 			console.log('纬度：' + res.latitude);
			// 			console.log('经度：' + res.longitude);
			
			// 			that.$geo.reverseGeocoder({
			// 				location: {
			// 					latitude: res.latitude,
			// 					longitude: res.longitude
			// 				},
			// 				success: function(res) {
			// 					console.log("解析地址成功", res);
			// 					console.log("当前地址：", res.result.address);
			// 					let component = res.result.address_component;
			
			// 					that.taskFormData.taskFormData = component
			
			// 					that.show = false
			// 					that.show2 = false
			// 				},
			// 				fail: function(res) {
			// 					uni.showToast({
			// 						title: '定位失败',
			// 						duration: 2000,
			// 						icon: "none"
			// 					})
			
			// 					that.form.latitude = '';
			// 					that.form.longitude = '';
			// 					that.form.pos_name = '';
			// 					console.log(res);
			// 				},
			// 				complete: function(res) { //无论成功失败都会执行
			
			// 				},
			// 			})
			// 		}
			// 	});
			},
			// assetsItemsClass(index)
			// {
			// 	let itemsClass = {
			// 		icon:true,
			// 		iconfont:true
			// 	}
				
			// 	itemsClass[this.assetsItems[index - 1].icon] = true
				
			// 	console.log(itemsClass)
			// 	console.log(index)
			// 	//itemsClass['icon-wenzi'] = true
				
				
			// 	//'icon','iconfont',this.assetsItems[index]]
				
			// 	//console.log(itemsClass)
				
			// 	return itemsClass;
			// },
			_onEditorReady() {
				// #ifdef MP-BAIDU
				this.editorCtx = requireDynamicLib('editorLib').createEditorContext('editor');
				this.onEditorReady()
				// #endif

				// #ifdef APP-PLUS || H5 ||MP-WEIXIN
				uni.createSelectorQuery().select('#editor').context((res) => {
				  this.editorCtx = res.context
				  this.onEditorReady()
				}).exec()
				// #endif
			},
			undo() {
				this.editorCtx.undo()
			},
			async save(){
				return new Promise((resolve,reject)=>{
					this.editorCtx.getContents({
						success(html){
							console.log(html)
							resolve(html)
						},
						fail(e){
							reject(e);
						}
					})
				})
			},
			onDelete(job,index){
				this.taskFormData.jobs.splice(index,1)
			},
			onAddAssets(){
				this.showAddAssets = true
			},
			closeAddAssets(){
				this.showAddAssets = false
			},
			openAddAssets(){
				 
			},
			onTimeStartFocus(){
				this.showPeriodTimeStartSel = true
			},
			onThumb(){
				let that = this
				uni.chooseImage({
					count:1,
					sourceType: ['album'], 
					success(result) {
						that.taskFormData.thumbUrl = result.tempFilePaths[0]
						console.log(result.tempFilePaths[0])
					}
				})
			}
		}
	}
</script>

<style scoped>
	 /* @import '@/css/editor.css'; */
	/* @import '@/css/iconfont/iconfont.css'; */
	
</style>

<style lang="scss" scoped>

page {
	background-color: white;
}

.u-page {
	padding: 0px 15px 0px 15px;
	background-color: #fff;
}

::v-deep .u-collapse-item__content__text {
	padding:0;
}

::v-deep .u-cell__value {
	color: #9f9f9f
}
</style>